import os
import random
import uuid
import numpy as np
import requests
import json
def start(prompt):
    url='https://ark.cn-beijing.volces.com/api/v3/images/generations'
    headers = {
        'Content-Type': 'application/json',
        'Authorization':'Bearer 87b0b68e-5aad-42b2-a330-d59c8b442af4',
    }
    data={
        'prompt':prompt,
        'model':'doubao-seedream-3-0-t2i-250415',
        'watermark':False
    }
    response = requests.post(url, headers=headers, data=json.dumps(data))
    print(response.text)
    img_url=response.json()['data'][0]['url']
    print(img_url)
    id='豆包'+str(np.random.random())
    print(id)
    image=requests.get(img_url)
    with open(f"static/images/{id}.jpg","wb") as f:
        f.write(image.content)
        f.close()
    return id